package com.hqyj.javaSpringBoot.modules.account.controller;

import com.hqyj.javaSpringBoot.modules.account.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Description：AccountController
 * @Author ：Cwd
 * @Date ：2021/8/26 10:20
 */
@Controller
public class AccountController {

    @Autowired
    private UserService userService;

    /**
     * 127.0.0.1:8083/login ---- get
     * @param modelMap
     * @return
     */
    @GetMapping("/login")
    public String loginPage(ModelMap modelMap){
        modelMap.put("template","account/login");
        return "indexSimple_2";
    }

    /**
     * 127.0.0.1:8083/register ---- get
     * @param modelMap
     * @return
     */
    @GetMapping("/register")
    public String register(ModelMap modelMap){
        modelMap.put("template","account/register");
        return "indexSimple_2";
    }

    /**
     * 127.0.0.1:8083/account/users ---- get
     * path路径与文件放置位置一致，则无需封装ModelMap
     * @return
     */
    @GetMapping("/account/users")
    public String usersPage(){
        return "index";
    }

    /**
     * 127.0.0.1:8083/account/roles ---- get
     * @return
     */
    @GetMapping("/account/roles")
    public String rolesPage(){
        return "index";
    }

    /**
     * 127.0.0.1:8083/account/resources ---- get
     * @return
     */
    @GetMapping("/account/resources")
    public String resourcesPage(){
        return "index";
    }

    /**
     * 127.0.0.1:8083/account/profile ---- get
     */
    @GetMapping("/account/profile")
    public String profilePage() {
        return "index";
    }

    /**
     * 127.0.0.1:8083/logout ---- get
     */
    @GetMapping("/logout")
    public String logout(){
        userService.logout();
        return "redirect:/login";
    }
}
